<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWechatMsg extends Migration
{
    public function up()
    {
        Schema::create('wechat_msg', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('wechat_record_msg_id')->default(0)->comment('消息记录主键ID');
            $table->integer('pic_attachment_id')->default(0)->comment('图片附件表主键ID');
            $table->integer('voice_attachment_id')->default(0)->comment('语音附件表主键ID');
            $table->integer('video_attachment_id')->default(0)->comment('视频附件表主键ID');
            $table->integer('thumb_video_pic_attachment_id')->default(0)->comment('视频缩略图附件表主键ID');
            $table->string('fromUserName',100)->default('')->comment('消息来源方');
            $table->string('toUserName',100)->default('')->comment('消息接收方');
            $table->string('msgId',100)->default('')->comment('微信消息ID');
            $table->string('msgType')->default('')->comment('消息类型 text event image voice video');
            $table->text('content')->nullable()->comment('内容');
            $table->string('picUrl',500)->default('')->comment('本地图片地址');
            $table->string('voiceUrl',500)->default('')->comment('本地语音地址');
            $table->string('videoUrl',500)->default('')->comment('本地视频地址');
            $table->string('thumbVideoPicUrl',500)->default('')->comment('本地视频缩略图图片地址');
            $table->timestamp('msgTime')->nullable()->comment('消息接收时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('wechat_msg');
    }
}
